import logging
import time

from selenium.webdriver.chrome import webdriver
from selenium.webdriver.common.by import By
from common.dologs import DoLog
dolog = DoLog().set_get_logger(logging.INFO)
class LoginPage():
    unamE = (By.CLASS_NAME, "inputBg")
    upassworD = (By.NAME, "password")
    usubmiT = (By.NAME, "submit")

    def login(self, n, p):
        try:
            dolog.info("开始捕获异常")
            wd = webdriver.WebDriver()
            wd.get("http://172.16.0.26/user.php")
            wd.implicitly_wait(10)

            wd.maximize_window()
            wd.find_element(*self.unamE).click()
            wd.find_element(*self.unamE).send_keys(*n)
            wd.find_element(*self.upassworD).click()
            wd.find_element(*self.upassworD).send_keys(*p)
            wd.find_element(*self.usubmiT).click()
        except Exception:
            dolog.error("捕获到异常")
            print(f'登录失败{Exception}')
        else:
            print("登录成功")
        finally:
            print("处理结束")
if __name__ == '__main__':
    LoginPage().login('admins','123456')
